home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11755 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
  4. Subject: Re: C/C++ knocks the crap out of Ada
  5. Date: Fri, 15 Mar 96 22:41:01 GMT
  6. Organization: none
  7. Message-ID: <826929661snz@genesis.demon.co.uk>
  8. References: <JSA.96Feb16135027@organon.com> <4hm6lo$eln@fred.netinfo.com.au> <4hml8s$a1q@solutions.solon.com> <DoBIoL.1JC@world.std.com> <4icai1INN608@gambier.ugrad.cs.ubc.ca>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!genesis.demon.co.uk
  13.  
  14. In article <4icai1INN608@gambier.ugrad.cs.ubc.ca>
  15.            c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
  16.  
  17. >In article <DoBIoL.1JC@world.std.com>,
  18. >Robert A Duff <bobduff@world.std.com> wrote:
  19.  
  20. > >So how can a C implementation check this range, without extending the
  21. > >syntax of the language?  There are many other examples.
  22. >
  23. >Quite frankly, you can't do it. If the integer is not used as any sort of array
  24. >index, you don't know what the range is. Here are some alternatives:
  25. >
  26. >1.      Use an enumerated type. Drawback: it's not an arithmetic type.
  27.  
  28. The C standard defines arithmetic types to include enumerated types.
  29.  
  30. >        Incrementing an enumerated variable, for instance, is a no no.
  31.  
  32. Maybe I'm missing your point but ++ requies an operand of a scalar type.
  33. It is perfectly legal for the operand to have an ennumerated type. As I
  34. understand it C++ is different in this respect.
  35.  
  36. >        An expression involving an enumerated type promotes it to an
  37. >        int, and can't be assigned back to the enumerated type.
  38.  
  39. The standard says "Each enumerated type shall be compatible with an integer
  40. type; the choice of type is implementation-defined". You can essentially do
  41. anything with an object of enumerated type that you can in general with
  42. integer types. Enumerated types are classed as integral types.
  43.  
  44. -- 
  45. -----------------------------------------
  46. Lawrence Kirby | fred@genesis.demon.co.uk
  47. Wilts, England | 70734.126@compuserve.com
  48. -----------------------------------------
  49.